package com.thinkwide.data.ormapping.sql;

import com.thinkwide.data.core.MFString;

import java.util.List;

public class MFSqlInsert extends MFSqlBase {
    public static final String INSERT = "Insert INTO %s (%s) Values(%s) ";

    public static String getInsertSql(String tableName, String fields, String values) {
        String strSQL = String.format(INSERT, tableName, fields, values);
        return strSQL;

    }

    public static String getInsertSqlParam(String tableName, List<String> fields) {

        String strFields = MFString.Empty;
        String strValues = MFString.Empty;

        for (String item : fields) {
            if (MFString.notNullOrEmpty(strFields)) {
                strFields = strFields + COMMA + item;
                strValues = strValues + COMMA + PARAM;
            } else {
                strFields = item;
                strValues = PARAM;
            }
        }

        String sSQL = MFSqlInsert.getInsertSql(tableName, strFields, strValues);
        return sSQL;
    }
}
